#!/usr/bin/env python

# $Id: find-working-cvs,v 1.1 2003/11/25 01:49:39 quarl Exp $

# Brute-force find at what point in time the automated tests stopped working.
# You better be using ccache!

# TODO: do a binary search instead of linear search.

range = ['2003-10-01', '2003-11-10']

import os, time

def ptime(t):
    return time.mktime(time.strptime(t, '%Y-%m-%d'))

def doit(d):
    print 'trying', d
    dir = '/tmp/t.' + d
    os.system('cvs co -D %s -d %s boinc' % (d,dir))
    os.chdir(dir)
    if 0 == os.system('./configure && make && cd test && ./test_uc.py'):
        raise SystemExit('Woohoo! %s' %d)

range = map(ptime, range)

t = range[1]
tmin = range[0]

while t > tmin:
    d = time.strftime('%Y-%m-%d', time.localtime(t))
    doit(d)
    t -= 86400
